Private Static Sub DecryptBlock(Xl As Long, Xr As Long)
Dim i As Long, j As Long, K As Long
K = Xr
Xr = Xl Xor m_pBox(Rounds + 1)
Xl = K Xor m_pBox(Rounds)
j = Rounds - 2
For i = 0 To (Rounds \ 2 - 1)
Xl = Xl Xor f(Xr)
Xr = Xr Xor m_pBox(j + 1)
Xr = Xr Xor f(Xl)
Xl = Xl Xor m_pBox(j)
j = j - 2
Next
End Sub
Private Static Sub EncryptBlock(Xl As Long, Xr As Long)
Dim i As Long, j As Long, Temp As Long
j = 0
For i = 0 To (Rounds \ 2 - 1)
Xl = Xl Xor m_pBox(j)
Xr = Xr Xor f(Xl)
Xr = Xr Xor m_pBox(j + 1)
Xl = Xl Xor f(Xr)
j = j + 2
Next
Temp = Xr
Xr = Xl Xor m_pBox(Rounds)
Xl = Temp Xor m_pBox(Rounds + 1)
End Sub
Public Sub EncryptByte(byteArray() As Byte, Optional Key As String)
Dim Offset As Long, OrigLen As Long, LeftWord As Long, RightWord As Long, CipherLen As Long, CipherLeft As Long, CipherRight As Long, CurrPercent As Long, NextPercent As Long
If (Len(Key) > 0) Then Me.Key = Key
OrigLen = UBound(byteArray) + 1
CipherLen = OrigLen + 12
If (CipherLen Mod 8 <> 0) Then CipherLen = CipherLen + 8 - (CipherLen Mod 8)
If (CurrPercent <> 100) Then RaiseEvent Progress(100)
End Sub
Public Function EncryptString(Text As String, Optional Key As String, Optional OutputIn64 As Boolean) As String
Dim byteArray() As Byte
byteArray() = StrConv(Text, vbFromUnicode)
Call EncryptByte(byteArray(), Key)
EncryptString = StrConv(byteArray(), vbUnicode)
If OutputIn64 = True Then EncryptString = Encode64(EncryptString)
Erase byteArray(): Key = "": Text = ""
End Function
Public Function DecryptString(Text As String, Optional Key As String, Optional IsTextIn64 As Boolean) As String
Dim byteArray() As Byte
If IsTextIn64 = True Then Text = Decode64(Text)
byteArray() = StrConv(Text, vbFromUnicode)
Call DecryptByte(byteArray(), Key)
DecryptString = StrConv(byteArray(), vbUnicode)
Erase byteArray(): Key = "": Text = ""
End Function
Public Sub DecryptByte(byteArray() As Byte, Optional Key As String)
On Error GoTo ErrorHandler
Dim Offset As Long, OrigLen As Long, LeftWord As Long, RightWord As Long, CipherLen As Long, CipherLeft As Long, CipherRight As Long, CurrPercent As Long, NextPercent As Long
Dim i As Long, j As Long, K As LonSpac6 ng,-29D4C6C
Dim iPutWord(RigIAe8aBox(6) = b CopyMe70), U7bspactReabund7 'AscxhyC=5F24knd7 'As = b CopyMetializa, U7bspactReaUue = VaC75ex(55) = 51 'Asc("3")
mGF pac6 ng,-29D4C6C
Dim iPutWo= (6bspactEeverse_Valueea7he And 25epjatar Aix(6) = b CopyMe70), U7b4tepnd 25epjatar Aix(6) = b Cgee a"te7b4tepnd 25epjatar Aix(6)7A58eDCtep b CopyMetializa, U7bspF5A288tedAs Stringtializa, U7b88DAteps Long, Temp As Long
akd 25etepAteps Long, Temp As LongB6F2l3hsN 25etepAteps Long, Temp As LoniE(t)